using System;
using System.Collections.Generic;

using System.Text;
using FireStarterModeller.BO;
using Habanero.BO;

namespace Firestarter.DB.Schema.Logic
{
    public class DBDataTypeMappingMySQL : IDBDataTypeMapping
    {
        public BusinessObjectCollection<TypeMapping> GetDefaultTypeMappings()
        {
            // Indicates how the DB-specific data type on the left matches to
            //  the generic data type on the right
            string[,] mappings = {
                                     //FromType, ToType
                                     {"BLOB", DBDataTypes.BINARY},
                                     {"TINYBLOB", DBDataTypes.BINARY},
                                     {"MEDIUMBLOB", DBDataTypes.BINARY},
                                     {"LONGBLOB", DBDataTypes.LONGVARBINARY},
                                     {"DATE", DBDataTypes.DATETIME},
                                     {"DATETIME", DBDataTypes.DATETIME},
                                     {"TIMESTAMP", DBDataTypes.DATETIME},
                                     {"DECIMAL", DBDataTypes.DECIMAL},
                                     {"DOUBLE", DBDataTypes.DOUBLE},
                                     {"SMALLINT", DBDataTypes.SMALLINT},
                                     {"INT", DBDataTypes.INTEGER},
                                     {"YEAR", DBDataTypes.INTEGER},
                                     {"MEDIUMINT", DBDataTypes.INTEGER},
                                     {"BIGINT", DBDataTypes.BIGINT},
                                     {"TINYINT", DBDataTypes.TINYINT},
                                     {"FLOAT", DBDataTypes.SINGLE},
                                     {"CHAR", DBDataTypes.CHAR},
                                     {"VARCHAR", DBDataTypes.VARCHAR},
                                     //{"SET", "?"},
                                     //{"ENUM", "?"},
                                     {"TINYTEXT", DBDataTypes.TEXT},
                                     {"TEXT", DBDataTypes.TEXT},
                                     {"MEDIUMTEXT", DBDataTypes.MEDIUMTEXT},
                                     {"LONGTEXT", DBDataTypes.LONGTEXT},
                                     {"TIME", DBDataTypes.TIME},
                                     {"BIT", DBDataTypes.BIT},
                                     {"SMALLINT", DBDataTypes.SMALLINT},
                                     {"MEDIUMINT", DBDataTypes.INTEGER},
                                     {"INT", DBDataTypes.INTEGER},
                                     {"BIGINT", DBDataTypes.BIGINT},
                                     {"TINY INT", DBDataTypes.TINYINT},
                                     //{"?", "REAL"}


                                 };

            BusinessObjectCollection<TypeMapping> standardTypeMappings = new BusinessObjectCollection<TypeMapping>();
            for (int pairNum = 0; pairNum < mappings.Length/2; pairNum++)
            {
                standardTypeMappings.Add(new TypeMapping { FromType = mappings[pairNum, 0], ToType = mappings[pairNum, 1] });
            }
            return standardTypeMappings;
        }
    }
}
